<?php
namespace Home\Model;
use Think\Model\RelationModel;

/**
 * Created by PhpStorm.
 * User: edvard
 * Date: 2016/6/14
 * Time: 11:32
 */
class RoomModel extends  RelationModel
{
    protected $tableName = 'room';

    protected $_link = array(
        'course' => array(
            'mapping_type' => self::HAS_ONE,
            'class_name' => 'course',
            'foreign_key' => 'id',
            'as_fields' => 'chn:course_chn,eng:course_eng'
        ),
        'teacher' => array(
            'mapping_type' => self::HAS_ONE,
            'class_name' => 'user',
            'foreign_key' => 'uid',
            'as_fields' => 'username:teacher_name'
        )
    );
}